from wormbane.model.armor import Armor
from wormbane.model.race import Race
from wormbane.model.weapon import Weapon
from wormbane.util.random_ import percent_chance, weighted_choice

import random

class Goblin(Race):
    size = 'small'
    color = 'green'
    frequency = 10.0

    @classmethod
    def create_equipment(cls):
        def random_metal():
            return weighted_choice(bronze = 20, iron = 70, steel = 10)

        yield Weapon(kind = random.choice(('axe', 'dagger', 'knife',
                                           'short sword', 'spear')),
                     material = random_metal())
        if percent_chance(50):
            yield Armor(kind = 'armor', material = 'leather')
        if percent_chance(50):
            yield Armor(kind = 'helm', material = random_metal())
        if percent_chance(50):
            yield Armor(kind = 'shirt', material = random_metal())
